#ifndef filestream_h__
#define filestream_h__

#include "istream.h"
#include <stdio.h>

namespace gecko
{

	// Stream for reading and writing from files on disk.
	class FileStream : public IStream
	{
	public:
		// Constructor.
		FileStream(const char* filename, eMode mode);

		// Close the file.
		void Close();

		// destructor
		virtual ~FileStream();

		// Seek to a new position in the stream.
		bool Seek(size_t offset, eSeekPos origin);

		// Get the position of the read/write.
		size_t GetPosition();

	protected:
		// do the actual read operation.
		virtual size_t ReadBuffer(char* buffer, size_t len);

		// do the actual write operation.
		virtual size_t WriteBuffer(char* buffer, size_t len);

		// the actual serialise operation.
		virtual size_t SerialiseBuffer(char* buffer, size_t len);

	private:
		FILE* m_fileHandle;
	};

}

#endif
